//
//  Person.m
//  王宇先_15_文件读写
//
//  Created by wyx on 16/3/29.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "Person.h"
#import "Dog.h"
@implementation Person
- (instancetype)init{
    self = [super init];
    if (self) {
        self.dog = [[Dog alloc] init];
    }
    return self;
}
/** 归档时调用此协议方法 */
- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeInteger:self.age forKey:@"age"];
}
/** 反归档时调用此协议方法 */
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.age = [aDecoder decodeIntegerForKey:@"age"];
    }
    return self;
}
@end
